#!/usr/bin/python
import random,\
    sys

MIN_VERTICES = 3
MAX_VERTICES = 15
INSTANCIAS  = 500
MAX_EJE_PESO = 50

for i in range(INSTANCIAS):
    
    v = random.randint(MIN_VERTICES,MAX_VERTICES)
    w =  random.randint(v,(v*(v-1))/2);
    k = random.randint(2,int(v/2)+1)
    ejes = set([])
    pesos = dict([])

    for t in range(w):
        (v1, v2) = (random.randint(0,v-1),random.randint(0,v-1))
        while v1 == v2 or (v1,v2)  in ejes or (v2,v1)  in ejes  :
            (v1, v2) = (random.randint(0,v-1),random.randint(0,v-1))
        ejes.add((v1, v2))    
        pesos["%d-%d" % (v1, v2) ] = random.randint(1,MAX_EJE_PESO)    
    print "%s %s %s" % (v,w,k)     
    for (e1,e2) in ejes:
        print "%s %s %s" % (e1,e2,pesos["%d-%d" % (e1, e2)])
print "0"
